\name{iALK}
\alias{iALK}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ ~~function to do ... ~~ }
\description{
  ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
iALK(freq.mat, length.vec1, length.vec2, stop.value = 0.001)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{freq.mat}{ ~~Describe \code{freq.mat} here~~ }
  \item{length.vec1}{ ~~Describe \code{length.vec1} here~~ }
  \item{length.vec2}{ ~~Describe \code{length.vec2} here~~ }
  \item{stop.value}{ ~~Describe \code{stop.value} here~~ }
}
\details{
  ~~ If necessary, more details than the description above ~~
}
\value{
  ~Describe the value returned
  If it is a LIST, use
  \item{comp1 }{Description of 'comp1'}
  \item{comp2 }{Description of 'comp2'}
  ...
}
\references{ ~put references to the literature/web site here ~ }
\author{ ~~who you are~~ }
\note{ ~~further notes~~ 

 ~Make other sections like Warning with \section{Warning }{....} ~
}
\seealso{ ~~objects to See Also as \code{\link{help}}, ~~~ }
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(freq.mat, length.vec1, length.vec2, stop.value=0.001)
	{
	if(length(length.vec1) != length(length.vec2) || length(length.vec2) != nrow(freq.mat) || c(length.vec1, length.vec2, apply(freq.mat, 1, sum)) <= 0)
		{
		print(paste(length(length.vec1),"=",length(length.vec2)))
		print(paste(length(length.vec2),"=",nrow(freq.mat)))
	    	stop("The number of length-classes must be the same in all data sets and all length-classes must have been sampled.")
		}
	nij1.temp <- length.vec1 * freq.mat/apply(freq.mat, 1, sum)
  	denom <- apply(nij1.temp, 2, sum)
	denom[denom==0] <- 1
	ialk.temp <- sweep(nij1.temp, 2, denom,"/")
	pj2.temp <- rep(1/ncol(freq.mat), ncol(freq.mat))
	criterion <- 10
	iterations <- 0
	while(criterion > stop.value)
		{
		iterations <- iterations + 1
		pj2.temp.old <- pj2.temp
		denom <- apply(sweep(ialk.temp, 2, pj2.temp, "*"),1, sum)
		denom[denom==0] <- 1
		alk.temp <- sweep(ialk.temp, 2, pj2.temp, "*")/denom
		nij2.temp <- length.vec2 * alk.temp
		pj2.temp <- apply(nij2.temp, 2, sum)/sum(nij2.temp)
		criterion <- sum(abs(pj2.temp - pj2.temp.old))
		}
	tablaIALK <<-nij2.temp
	iteraciones <<- iterations 
	#output <- list(nij2.temp, "Number of iterations to convergence" = iterations)
	return(nij2.temp)
	}
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
